package cn.wk.order.controller;

import cn.wk.basic.utils.AjaxResult;
import cn.wk.basic.utils.SystemContext;
import cn.wk.order.service.IProductOrderService;
import cn.wk.user.domain.LoginInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/productOrder")
public class ProductOrderController {
    @Autowired
    private IProductOrderService productOrderService;

    @RequestMapping("/submitOrder")
    public AjaxResult goBuy(@RequestBody Map<String,Object> map, HttpServletRequest request){
       try{
           //获取当前登录对象
           LoginInfo loginInfo = SystemContext.getLoginInfo(request);
           String submitOrder = productOrderService.submitOrder(map, loginInfo);
           return new AjaxResult().setResultObj(submitOrder);
       }catch(Exception e){
           return new AjaxResult(e.getMessage());
       }
    }
}
